import request from './request';

// 常识模块API
export function getCommonSenseQuestions(params: any) {
  return request({
    url: '/api/commonSense/questions',
    method: 'get',
    params,
  });
}

// 通用接口名称
export function getQuestions(params: any) {
  return getCommonSenseQuestions(params);
}

export function addCommonSenseQuestion(data: any) {
  return request({
    url: '/api/commonSense/questions',
    method: 'post',
    data,
  });
}

// 通用接口名称
export function addQuestion(data: any) {
  return addCommonSenseQuestion(data);
}

export function updateCommonSenseQuestion(id: string, data: any) {
  return request({
    url: `/api/commonSense/questions/${id}`,
    method: 'put',
    data,
  });
}

// 通用接口名称
export function updateQuestion(id: string, data: any) {
  return updateCommonSenseQuestion(id, data);
}

export function deleteCommonSenseQuestion(id: string) {
  return request({
    url: `/api/commonSense/questions/${id}`,
    method: 'delete',
  });
}

// 批量删除常识题目
export function batchDeleteCommonSenseQuestions(ids: string[]) {
  return request({
    url: '/api/commonSense/questions/batch',
    method: 'delete',
    data: ids
  });
}

// 通用接口名称
export function deleteQuestion(id: string) {
  return deleteCommonSenseQuestion(id);
}

// 通用批量删除接口名称
export function batchDeleteQuestions(ids: string[]) {
  return batchDeleteCommonSenseQuestions(ids);
}

// 提交答案
export function submitAnswer(data: any) {
  return request({
    url: '/api/commonSense/submit',
    method: 'post',
    data,
  });
}

// 获取单个常识题目
export function getCommonSenseQuestion(id: string) {
  return request({
    url: `/api/commonSense/questions/${id}`,
    method: 'get',
  });
}

// 通用接口名称
export function getQuestion(id: string) {
  return getCommonSenseQuestion(id);
}

// 获取练习题目
export function getPracticeQuestions(params: any) {
  return request({
    url: '/api/commonSense/practice',
    method: 'get',
    params,
  });
}

// 通用练习接口名称
export function getPractice(params: any) {
  return getPracticeQuestions(params);
}